'''
创建多个子进程
'''
from multiprocessing import Process
from time import sleep
import os, sys


def th1():
    sleep(3)
    print('吃饭')
    print(os.getppid(), '-->', os.getpid())


def th2():
    sleep(4)
    print('睡觉')
    print(os.getppid(), '-->', os.getpid())


def th3():
    sys.exit('不打豆豆')
    sleep(5)
    print('打豆豆')
    print(os.getppid(), '-->', os.getpid())


job = []
for th in [th1, th2, th3]:
    process = Process(target=th)
    job.append(process)
    process.start()


# 所有进程都结束
for i in job:
    i.join()
# job[-1].join()
print('事件执行完毕')
